FROM golang:1.16.5-alpine AS builder

RUN mkdir -p /root/hedge && \
    mkdir -p /root/go/src && \
    mkdir -p /root/go/bin && \
    mkdir -p /root/go/pkg

ENV GOPATH /root/go
ENV GOBIN /root/go/bin

WORKDIR /tmp

RUN apk add git && \
    git clone https://gitee.com/hacker61/hedge.git && \
    cp -r /tmp/hedge/* /root/hedge/ && \
    rm -rf /tmp/hedge

WORKDIR /root/hedge

#COPY . .

RUN go build && \
    go install

FROM alpine

ENV CONFIG_PATH=/etc/hedge
COPY --from=builder /root/go/bin/hedge /bin/hedge
#COPY config.json /root/config.json

ENTRYPOINT ["/bin/hedge"]
